Skip to content

Add Codex CLI agent integration#172

Open
jcleira wants to merge 13 commits intomainfrom
minion/implement-implement
Open

Add Codex CLI agent integration#172
jcleira wants to merge 13 commits intomainfrom
minion/implement-implement

Conversation

@jcleira
Copy link
Copy Markdown
Member

@jcleira jcleira commented Apr 7, 2026

Summary

  • Add OpenAI Codex CLI (codex) as a supported AI agent alongside Claude Code
  • Introduce internal/agent/codex/ package with process detection, session directory lookup, and Detector implementation
  • Add pluggable detector registry (agent.Register/agent.NewDetector) so hooks select the detector based on the agent config setting
  • Update pre-commit and post-commit hooks to use the registry instead of hardcoding Claude Code
  • Add PARTIO_AGENT environment variable support for overriding the agent name
  • Add diagnostic logging for checkpoint linking failures
  • Table-driven unit tests for codex detector and registry

Why

Codex CLI is a widely used AI coding agent. Without this change, Codex-assisted commits are attributed as 100% human work and no session context is preserved. The agent.Detector interface was already designed to be pluggable — this PR delivers on that design.

Test plan

  • go test ./... passes
  • golangci-lint run passes
  • New tests cover codex detector (Name, IsRunning, FindSessionDir)
  • New tests cover registry (NewDetector with registered and unknown agents)
  • Manual: set PARTIO_AGENT=codex and verify partio status reports codex

🤖 Generated with Claude Code

minion[bot] and others added 2 commits April 7, 2026 07:06
Add a pluggable agent registry and implement the Codex CLI detector
alongside the existing Claude Code detector. The hooks now resolve
the detector from config rather than hardcoding Claude Code.

- internal/agent/registry.go: agent name → detector factory registry
- internal/agent/codex/: Codex CLI detector (process detection, session dir)
- internal/agent/claude/register.go: register claude-code detector
- Update pre-commit and post-commit hooks to use registry with fallback
- Fix flaky precommit_test timing (5ms → 50ms sleep)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add structured debug and warn logging in the post-commit hook to help
users diagnose why commits may not receive Partio-Checkpoint trailers.

- Warn-level logging at each early return explaining why no trailer was
  added (agent inactive, commit already processed, session condensed)
- Debug-level logging of commit file paths and session info for
  diagnosing path mismatch issues (visible with PARTIO_LOG_LEVEL=debug)
- Add git.DiffNameOnly helper to extract changed file paths from commits

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jcleira jcleira changed the title Add Codex CLI agent integration Add diagnostic logging for checkpoint linking failures Apr 7, 2026
minion[bot] and others added 3 commits April 7, 2026 12:44
## Objective

Update all workflows to use minions v0.0.5.

## Why

v0.0.5 fixes the root cause of all "no changes" failures —
Claude was unable to write files because bypassPermissions
mode was not set.

## How

Updated go install version tag in all workflow files.

Partio-Checkpoint: 0ecbe84f5950
Partio-Attribution: 100% agent
Upgrade early-exit log messages in the post-commit hook from Debug to
Warn level so users running PARTIO_LOG_LEVEL=debug (or default) can
immediately see why no Partio-Checkpoint trailer was added to a commit.

Each exit path now emits a structured "post-commit: no checkpoint created"
warning with the specific reason (no pre-commit state, no active agent,
commit already processed, session already condensed) and relevant context
(commit hash, session ID, state file path).

Also adds a Debug-level log after session lookup showing the resolved
session path, helping diagnose path mismatch issues.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Allow overriding the agent name via PARTIO_AGENT env var, completing
the documented environment variable support in CLAUDE.md.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jcleira jcleira changed the title Add diagnostic logging for checkpoint linking failures Add Codex CLI agent integration Apr 7, 2026
minion[bot] added 8 commits April 8, 2026 08:29
Partio-Checkpoint: 35c4fbedc789
Partio-Attribution: 100% agent
## Objective

Detect any running AI agent automatically instead of requiring
PARTIO_AGENT env var to be set to the correct agent name.

## Why

Users running Codex, Claude Code, or any other agent shouldn't
have to configure PARTIO_AGENT. The hooks should detect whichever
agent is active and capture its session.

## How

- Added DetectActive() to agent registry that checks IsRunning()
  on all registered detectors
- Pre-commit hook now auto-detects if no explicit agent is
  configured, or if the configured agent isn't running
- Pre-commit state now includes AgentName so post-commit uses the
  detected agent (not the configured default)
- Post-commit reads agent name from state, falls back to config
- Fixed codex FindSessionDir test to use temp HOME dir

Partio-Checkpoint: 205608af50b1
Partio-Attribution: 100% agent
## Objective

Capture Codex CLI session data in checkpoints and auto-detect
any running agent without requiring PARTIO_AGENT config.

## Why

The Codex integration only detected the process but captured no
session data. The hooks had Claude-specific type assertions that
skipped all other agents. Users shouldn't have to set an env var
to tell Partio which agent they're using.

## How

- Added SessionParser interface to agent package — any detector
  that can provide session data implements FindLatestSession
- Implemented Codex JSONL parser (parse_jsonl.go) that extracts
  session ID, prompt, transcript, token counts from Codex format
- Implemented FindLatestSession for Codex that matches sessions
  to repos by comparing cwd from session_meta
- Replaced all detector.(*claude.Detector) type assertions in
  hooks with detector.(agent.SessionParser) interface checks
- Added DetectActive() to registry that checks all registered
  detectors — hooks auto-detect first, fall back to config
- Pre-commit state now carries AgentName for post-commit
- Default agent config changed from "claude-code" to "" (auto)
- Fixed codex test to use temp HOME dir

Partio-Checkpoint: b34e9e44f11a
Partio-Attribution: 100% agent
## Objective

Stop tracking .partio/sessions/ and .partio/state/ in git.

## Why

These files update on every commit (session tracking, processed
commits list) and create noise in git status.

## How

Added .partio/sessions/ and .partio/state/ to .gitignore and
removed them from tracking.

Partio-Checkpoint: c01093c0919c
Partio-Attribution: 100% agent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant